package com.itheima.HomeWork_day06;

public class ArraySort {

    public static void main(String[] args) {

        int[] arr={91,27,46,38,50};

        //冒泡排序:
        System.out.println("冒泡排序(大-->小);");
        getBubbleSort(arr);

    }





    //冒泡排序
    public static void getBubbleSort(int[] arr) {

       for (int i = 0; i < arr.length - 1; i++) {
           for (int j = 0; j < arr.length-1-i; j++) {

               //判断元素大小,,从大到小排序
               if (arr[j]<arr[j+1]){
                   int temp = arr[j];
                   arr[j]=arr[j+1];
                   arr[j+1]=temp;
               }
           }
       }
        printArr(arr);
    }


    //遍历输出排序后的数组
    public static void printArr(int[] ar) {
        for (int a:ar) {
            System.out.print(a+" ");
        }
    }


}
